using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class DebugStreamer : MonoBehaviour
{
	private void Awake()
	{
		this.guiObj = new GameObject("Debug Streamer");
		this.guiObj.AddComponent<Text>();
		this.guiObj.transform.position = Vector3.zero;
		this.guiObj.transform.localScale = new Vector3(0f, 0f, 1f);
		this.guiObj.name = "Debug Streamer";
		this.guiTxt = this.guiObj.GetComponent<Text>();
		this._anchorAt = this.anchorAt;
		this._message = DebugStreamer.message;
		this.SetPosition();
	}

	private void Start()
	{
	}

	private void Update()
	{
		if (this._anchorAt != this.anchorAt || this._pixelOffset != (float)this.pixelOffset)
		{
			this._anchorAt = this.anchorAt;
			this._pixelOffset = (float)this.pixelOffset;
			this.SetPosition();
		}
		if (this._message != DebugStreamer.message)
		{
			this._message = DebugStreamer.message;
			if (this.showLineMovement)
			{
				this.messageHistory.Insert(0, DebugStreamer.message + "\t" + this.pattern[this.patternIndex]);
				this.messageHistoryLength = this.messageHistory.Count;
			}
			else
			{
				this.messageHistory.Insert(0, DebugStreamer.message);
			}
			this.messageHistoryLength = this.messageHistory.Count;
			this.patternIndex = (this.patternIndex + 1) % 4;
			while (this.messageHistoryLength > this.numberOfLines)
			{
				this.messageHistory.RemoveAt(this.messageHistory.Count - 1);
				this.messageHistoryLength = this.messageHistory.Count;
			}
			this.displayText = string.Empty;
			for (int i = 0; i < this.messageHistory.Count; i++)
			{
				if (i == 0)
				{
					this.displayText = (this.messageHistory[i] as string);
				}
				else
				{
					this.displayText = (this.messageHistory[i] as string) + "\n" + this.displayText;
				}
			}
			this.guiTxt.text = this.displayText;
		}
	}

	public void OnDisable()
	{
		if (this.guiObj != null)
		{
			UnityEngine.Object.DestroyImmediate(this.guiObj.gameObject);
		}
	}

	public void SetPosition()
	{
		 
	}

	public static string message;

	public bool showLineMovement;

	public TextAnchor anchorAt = TextAnchor.LowerLeft;

	public int numberOfLines = 5;

	public int pixelOffset = 5;

	private GameObject guiObj;

	private  Text guiTxt;

	private TextAnchor _anchorAt;

	private float _pixelOffset;

	private bool _showLineMovement;

	private string _message;

	private ArrayList messageHistory = new ArrayList();

	private int messageHistoryLength;

	private string displayText;

	private int patternIndex;

	private string[] pattern = new string[]
	{
		"-",
		"\\",
		"|",
		"/"
	};
}
